"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_evaluation_index = require("../../../api/evaluation/index.js");
const config_app = require("../../../config/app.js");
const utils_tools = require("../../../utils/tools.js");
const stores_userInfo = require("../../../stores/userInfo.js");
if (!Array) {
  const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  const _easycom_up_rate2 = common_vendor.resolveComponent("up-rate");
  const _easycom_up_album2 = common_vendor.resolveComponent("up-album");
  const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  const _easycom_up_gap2 = common_vendor.resolveComponent("up-gap");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_up_tabs2 + _easycom_up_rate2 + _easycom_up_album2 + _easycom_up_empty2 + _easycom_up_gap2 + _easycom_up_toast2)();
}
const _easycom_up_tabs = () => "../../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
const _easycom_up_rate = () => "../../../node-modules/uview-plus/components/u-rate/u-rate.js";
const _easycom_up_album = () => "../../../node-modules/uview-plus/components/u-album/u-album.js";
const _easycom_up_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_up_gap = () => "../../../node-modules/uview-plus/components/u-gap/u-gap.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_up_tabs + _easycom_up_rate + _easycom_up_album + _easycom_up_empty + _easycom_up_gap + _easycom_up_toast)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "mobEvaluationTip",
  setup(__props) {
    const userInfoStore = stores_userInfo.useUserInfoStore();
    const uToastRef = common_vendor.ref(null);
    const newsTab = common_vendor.reactive([
      { name: "本月评价（0）" },
      { name: "全部评价（0）" }
    ]);
    const degreeList = common_vendor.reactive([
      { id: 3, name: "满意", num: 8 },
      { id: 2, name: "一般", num: 2 },
      { id: 1, name: "不满意", num: 2 }
    ]);
    const data = common_vendor.reactive({
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        policeQueryType: 0,
        // 0 本月
        policeUserId: userInfoStore.userInfo.userId,
        scoreStar: ""
      },
      list: [],
      total: 0,
      countParam: {
        policeQueryType: 0,
        // 0 本月
        policeUserId: userInfoStore.userInfo.userId
      }
    });
    const { queryParam, list, total, countParam } = common_vendor.toRefs(data);
    const onTypeItem = (item) => {
      if (item.index === 0) {
        queryParam.value.policeQueryType = item.index;
        countParam.value.policeQueryType = item.index;
      } else {
        queryParam.value.policeQueryType = "";
        countParam.value.policeQueryType = "";
      }
      reRenderList();
      getEvaluationCount();
    };
    const changeScoreType = (item) => {
      if (queryParam.value.scoreStar == item.id) {
        queryParam.value.scoreStar = "";
      } else {
        queryParam.value.scoreStar = item.id;
      }
      reRenderList();
    };
    const getEvaluationCount = () => {
      api_evaluation_index.listEvaluationCount(countParam.value).then((res) => {
        const { data: data2 } = res;
        degreeList[0].num = data2.satisfiedCount;
        degreeList[1].num = data2.generalCount;
        degreeList[2].num = data2.dissatisfiedCount;
        newsTab[0].name = `本月评价（${data2.monthCount}）`;
        newsTab[1].name = `全部评价（${data2.sumCount}）`;
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const getEvaluationList = () => {
      common_vendor.index.showLoading({
        title: "加载中",
        mask: true
      });
      api_evaluation_index.listEvaluation(queryParam.value).then((res) => {
        common_vendor.index.hideLoading();
        const { data: data2 } = res;
        data2.records = data2.records ?? [];
        data2.records = processImg(data2.records);
        list.value = [...list.value, ...data2.records];
        total.value = data2.total;
      }).catch((err) => {
        common_vendor.index.hideLoading();
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const processImg = (arr) => {
      if (arr.length) {
        arr = arr.map((item) => {
          if (item.imgUrl) {
            item.imgUrl = item.imgUrl.split(",");
            if (item.imgUrl.length) {
              item.imgUrl = item.imgUrl.map((img) => {
                img = config_app.imgPrefix + img;
                return img;
              });
            }
          }
          return item;
        });
      }
      return arr;
    };
    const reRenderList = () => {
      list.value = [];
      total.value = 0;
      queryParam.value.pageNum = 1;
      getEvaluationList();
    };
    const initData = () => {
      getEvaluationList();
      getEvaluationCount();
    };
    common_vendor.onLoad(() => {
      initData();
    });
    common_vendor.onReachBottom(() => {
      let allTotal = queryParam.value.pageNum * queryParam.value.pageSize;
      if (allTotal < total.value) {
        queryParam.value.pageNum++;
        getEvaluationList();
      } else {
        uToastRef.value.show({
          type: "info",
          message: "暂无更多数据"
        });
        return;
      }
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(onTypeItem),
        b: common_vendor.p({
          list: common_vendor.unref(newsTab),
          lineColor: "#0A8CFE",
          lineWidth: "70rpx",
          activeStyle: {
            color: "#0A8CFE",
            fontSize: "29rpx"
          },
          inactiveStyle: {
            color: "#000",
            fontSize: "29rpx"
          }
        }),
        c: common_vendor.f(common_vendor.unref(degreeList), (item, index, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.t(item.num),
            c: common_vendor.n(common_vendor.unref(queryParam).scoreStar == item.id ? "active" : "unactive"),
            d: index,
            e: common_vendor.o(($event) => changeScoreType(item), index)
          };
        }),
        d: common_vendor.unref(list).length
      }, common_vendor.unref(list).length ? {
        e: common_vendor.f(common_vendor.unref(list), (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.itemName),
            b: "363d4bf7-1-" + i0,
            c: common_vendor.o(($event) => item.scoreStar = $event, index),
            d: common_vendor.p({
              inactiveColor: "#CCCCCC",
              activeColor: "#F55300",
              size: "21",
              count: "3",
              readonly: true,
              modelValue: item.scoreStar
            }),
            e: common_vendor.t(item.scoreStar == 3 ? "满意" : item.scoreStar == 2 ? "一般" : item.scoreStar == 1 ? "不满意" : ""),
            f: common_vendor.t(item.content),
            g: item.imgUrl && item.imgUrl.length
          }, item.imgUrl && item.imgUrl.length ? {
            h: "363d4bf7-2-" + i0,
            i: common_vendor.p({
              urls: item.imgUrl,
              space: "20rpx",
              singleSize: "155rpx",
              multipleSize: "155rpx",
              autoWrap: true,
              maxCount: 3,
              unit: "rpx"
            })
          } : {}, {
            j: common_vendor.t(item.appraiseUserName),
            k: common_vendor.t(common_vendor.unref(utils_tools.EncryptTel)(item.phonenumber)),
            l: common_vendor.t(item.createTime ? common_vendor.unref(common_vendor.dayjs)(item.createTime).format("YYYY-MM-DD hh:mm:ss") : ""),
            m: index
          });
        })
      } : {
        f: common_vendor.p({
          mode: "data",
          text: "暂无记录",
          icon: "http://cdn.uviewui.com/uview/empty/data.png"
        })
      }, {
        g: common_vendor.p({
          height: "10"
        }),
        h: common_vendor.sr(uToastRef, "363d4bf7-5", {
          "k": "uToastRef"
        })
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-363d4bf7"]]);
wx.createPage(MiniProgramPage);
